package com.huarui.memcached;


import java.util.concurrent.TimeoutException;

import net.rubyeye.xmemcached.MemcachedClient;
import net.rubyeye.xmemcached.exception.MemcachedException;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;




import junit.framework.TestCase;

public class MemcachedTestCase extends TestCase {
	
	BeanFactory  context;
	@Before
	public void setUp() throws Exception {
		context = new ClassPathXmlApplicationContext(new String[] { "spring/spring-framework.xml" });
	}
	
	@Test
	public void testPut(){
		
		net.rubyeye.xmemcached.MemcachedClient  mc = (MemcachedClient)  context.getBean("memcachedClient");
		try {
			mc.set("one", 0 , "1" );
			assertEquals("1", mc.get("one"));
		} catch (TimeoutException e) {
			
		} catch (InterruptedException e) {
		
		} catch (MemcachedException e) {
	
		}
		
		
//		MemcachedClientWrapper  mc = (MemcachedClientWrapper)  context.getBean("memcachedClient");
	}

}
